package com.zhuss.repair.repair;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.food.food.UpdateFoodBo;
import com.zhuss.bean.bo.repair.repair.BackRepairBo;
import com.zhuss.bean.bo.repair.repair.CreateRepairBo;
import com.zhuss.bean.bo.repair.repair.DeleteRepairBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;

/**
 * 报修操作service（基本操作）
 * @author hxx
 * @Date 2020/02/28 16:01
 *
 */
@Component("repairOperateService")
public class RepairOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("repairCreate")
	private Processor<Object, CreateRepairBo> repairCreate;
	
	/*@Autowired
	@Qualifier("foodUpdate")
	private Processor<Object, UpdateFoodBo> foodUpdate;
	
	@Autowired
	@Qualifier("foodStart")
	private Processor<Object, StartFoodBo> foodStart;
	
	@Autowired
	@Qualifier("foodStop")
	private Processor<Object, StopFoodBo> foodStop;*/
	
	@Autowired
	@Qualifier("repairDelete")
	private Processor<Object, DeleteRepairBo> repairDelete;
	
	@Autowired
	@Qualifier("repairBack")
	private Processor<Object, BackRepairBo> repairBack;
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws WpsException {
		
		CreateRepairBo bo = (CreateRepairBo) param;
		
		repairCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws WpsException {
    	
		UpdateFoodBo bo = (UpdateFoodBo) param;
		
		//foodUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws WpsException {
		
		DeleteRepairBo bo = (DeleteRepairBo) param;
		
		repairDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 撤回
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void back(Object param) throws WpsException {
		
		BackRepairBo bo = (BackRepairBo) param;
		
		repairBack.process(bo);
		
		return null;
	}
	
	/**
	 * 停用餐品
	 */
	/*@Transactional(rollbackFor = Exception.class)
	protected Void stop(Object param) throws WpsException {
		
		StopFoodBo bo = (StopFoodBo) param;
		
		foodStop.process(bo);
		
		return null;
	}*/
	
}

